<?php

use think\migration\Seeder;

class AlarmNewsData extends Seeder
{
    /**
     * 报警信息
     * 采用批量化内容进行
     */
    public function run()
    {
        $table = $this->table('alarm_news');

        $rows = [];
        $i    = 0;
        $num  = 100;
        while ($num > 0) {
            $readTypeArr     = [0, 1];
            $randomReadTKeys = array_rand($readTypeArr);

            $rows[] = [
                // step1:类型
                'alarm_type'  => mt_rand(1, 3), //1站点报警/2工况报警/3重污染报警
                'time_type'   => mt_rand(1, 2), //1实时/2预报
                //step2:标题和内容
                'title'       => '提示' . $i,
                'content'     => '内容' . $i,
                //step3:已读和未读
                'is_read'     => $readTypeArr[$randomReadTKeys],
                //step4:相关ID
                'region_id'   => 53,
                //step4:时间
                'create_time' => date('Y-m-d H:i:s'),
            ];
            $num--;
            $i++;
        }

        $table->insert($rows)->save();
    }
}